import pymysql

db = pymysql.connect(host='localhost',
                     user='root',
                     password='666666',
                     database='my_database',
                     charset='utf8')

# 使用 cursor() 方法创建一个游标对象 cursor
cursor = db.cursor()

# 使用 execute()  方法执行 SQL 查询
cursor.execute("SELECT VERSION()")

# 使用 fetchone() 方法获取单条数据.
data = cursor.fetchone()

print("数据库连接成功！")
id = 'jenny'
sql_query = "DELETE FROM employees WHERE name = %s"

cursor.execute(sql_query, (id,))
db.commit()
# cursor.execute(sql_query)
# sql = "insert into test(FIRST_,SECOND_,THIRD_,FOURTH_,FIFTH_) values ('MAC','MOTH','20','M','2000')"
result = cursor.fetchall()

print(result)
# cursor.execute(sql)
# 关闭数据库连接
db.close()
